package com.walker.order.rabitmq;


import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class MessageSender {

	public static void main(String[] args) {
		Connection connection = null;
		Channel channel = null;
		try {
			ConnectionFactory factory = new ConnectionFactory();
			connection = factory.newConnection();
			channel = connection.createChannel();
			String queueName = "product-queue";
			channel.queueDeclare(queueName, false, false, false, null);
			String message = "hello walker myrabit 2019";
			channel.basicPublish("", queueName, null, message.getBytes());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				if(channel != null) {
					channel.close();
				}
				if(connection != null) {
					connection.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			} 
		}

	}

}
